package com.wty.design.creational.singleton;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author wangtengyu
 * @Create 2018-09-18-15:41
 */
public class ContainerSingleton {

    private ContainerSingleton(){

    }

    private static Map<String,Object> singletonMap=new HashMap<String,Object>();


    public static void putInstance(String key,Object instance){
        if(key!=null && instance != null){
            if(!singletonMap.containsKey(key)){
                singletonMap.put(key,instance);
            }
        }
    }
    public static Object getInstance(String key){
        return singletonMap.get(key);
    }

}
